﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using POSSystem.BLL;

namespace WebUI.Controls
{
    public partial class BaseControl : System.Web.UI.UserControl
    {
        static SystemVariables sysVars;
        
        public const string SESSION_USER = "session_user";
        public View_Users SessionUser
        {
            get
            {
                return (View_Users)Session[SESSION_USER];
            }
            set
            {
                Session[SESSION_USER] = value;
            }
        }

        public static SystemVariables SysVars
        {
            get { return SystemVariables.SysVars; }
        }

        protected void Page_Load(object sender, EventArgs e)
        {
            if (SessionUser == null)
                Response.Redirect("~/Login.aspx");
        }

        public void ShowErrorMessage(Control parent, String msg)
        {
            String div = "<div class='{0}'>{1}</div>";
            Literal lit = new Literal();
            lit.Text = String.Format(div, "labelError", msg);

            parent.Controls.Add(lit);
        }

        public void ShowHintMessage(Control parent, String msg)
        {
            String div = "<div class='{0}'>{1}</div>";
            Literal lit = new Literal();
            lit.Text = String.Format(div, "labelHint", msg);

            parent.Controls.Add(lit);
        }


    }
}